package org.dreamwork.jasmine2.web.controls;

import org.dreamwork.util.VirtualFile;
import org.dreamwork.util.NameValueCollection;
import org.dreamwork.jasmine2.engine.HttpContext;
import org.dreamwork.jasmine2.engine.JasmineRequest;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by IntelliJ IDEA.
 * User: seth
 * Date: 2009-9-3
 * Time: 14:11:32
 */
public class FileControl extends TextBox {
    private VirtualFile file;

    public FileControl () {
        setAttribute ("type", "file");
    }

    public VirtualFile getVirtualFile () {
        return file;
    }

    @Override
    public void postbackData (NameValueCollection props) {
        HttpServletRequest req = HttpContext.current ().getRequest ();
        if (req instanceof JasmineRequest) {
            JasmineRequest request = (JasmineRequest) req;
            file = request.getVirtualFile (id);
        }
    }
}